package com.huawei.appgallery.common.media.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import com.huawei.appgallery.common.media.api.IMediaSelectProtocol;
import com.huawei.appgallery.common.media.api.IMediaSelectResult;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.hmf.annotation.ActivityDefine;
import o.ble.a;
import o.blf;
import o.ceh;
import o.PermissionChecker;
import o.fho;
import o.fiu;
import o.fiv;
import o.fjb;
import o.fjc;
import o.fjf;

@ActivityDefine(alias = "MediaSelect", protocol = IMediaSelectProtocol.class, result = IMediaSelectResult.class)
public class StoragePermissionCheckActivity extends AbstractBaseActivity implements ceh {
    private fiv ˊॱ = fiv.ॱ(this);

    public void onCreate(Bundle bundle) {
        requestWindowFeature(1);
        super.onCreate(bundle);
        if (bundle != null) {
            blf.ˋ.ˋ("StoragePermissionCheckA", "onCreate hasOpen, do nothing");
            return;
        }
        View view = new View(this);
        view.setAlpha(0.0f);
        setContentView(view);
        getWindow().setBackgroundDrawableResource(a.ˎ);
        ᐝ();
    }

    private void ᐝ() {
        if (!PermissionChecker.ˋ(this, 16)) {
            ͺ();
        }
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        PermissionChecker.ˎ(this, i, strArr, iArr);
    }

    public void ˏ(int i, int i2) {
        Object obj = null;
        if (i == 16 && i2 != -1) {
            obj = 1;
        }
        if (obj != null) {
            ͺ();
        } else {
            finish();
        }
    }

    private void ͺ() {
        IMediaSelectProtocol iMediaSelectProtocol = (IMediaSelectProtocol) this.ˊॱ.ॱ();
        fjb ˎ = fho.ˏ().ˋ("Media").ˎ("MediaSelectImpl");
        IMediaSelectProtocol iMediaSelectProtocol2 = (IMediaSelectProtocol) ˎ.ˊ();
        iMediaSelectProtocol2.setMediaType(iMediaSelectProtocol.getMediaType());
        iMediaSelectProtocol2.setMimeTyes(iMediaSelectProtocol.getMimeTyes());
        iMediaSelectProtocol2.setMaxSelectSize(iMediaSelectProtocol.getMaxSelectSize());
        iMediaSelectProtocol2.setMaxSelectFileSize(iMediaSelectProtocol.getMaxSelectFileSize());
        iMediaSelectProtocol2.setSelectedImages(iMediaSelectProtocol.getSelectedImages());
        iMediaSelectProtocol2.setCheckFileExtendNames(iMediaSelectProtocol.getCheckFileExtendNames());
        iMediaSelectProtocol2.setSelectForHeadImg(iMediaSelectProtocol.getSelectForHeadImg());
        fiu.ˊ().ॱ((Context) this, ˎ, new fjc<IMediaSelectResult>(this) {
            final /* synthetic */ StoragePermissionCheckActivity ˋ;

            {
                this.ˋ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ˋ(i, (IMediaSelectResult) obj);
            }

            public void ˋ(int i, IMediaSelectResult iMediaSelectResult) {
                if (i == -1 && iMediaSelectResult != null) {
                    fjf ˊ = fjf.ˊ(this.ˋ);
                    ((IMediaSelectResult) ˊ.ॱ()).setSelectedMedias(iMediaSelectResult.getSelectedMedias());
                    ˊ().setResult(-1, ˊ.ˊ());
                }
                ˊ().finish();
            }
        });
    }
}
